package ru.geyes.screw.collections;

import java.util.Collection;
import java.util.Iterator;
import java.util.ListIterator;

/**
 * @author alex
 *         date 25.05.2008
 *         time 18:47:00
 */
public class ImmutableList<T> extends ArrayListX<T> {
    public ImmutableList(int initialCapacity) {
        super(initialCapacity);
    }

    public ImmutableList() {
        super();
    }

    public ImmutableList(Collection<? extends T> c) {
        super(c);
    }

    public T set(int index, T element) {
        throw new UnsupportedOperationException();
    }

    public T remove(int index) {
        throw new UnsupportedOperationException();
    }

    public boolean remove(Object o) {
        throw new UnsupportedOperationException();
    }

    public boolean removeAll(Collection<?> c) {
        throw new UnsupportedOperationException();
    }

    public boolean retainAll(Collection<?> c) {
        throw new UnsupportedOperationException();
    }

    public boolean add(T t) {
        throw new UnsupportedOperationException();
    }

    public void add(int index, T element) {
        throw new UnsupportedOperationException();
    }

    public boolean addAll(Collection<? extends T> c) {
        throw new UnsupportedOperationException();
    }

    public boolean addAll(int index, Collection<? extends T> c) {
        throw new UnsupportedOperationException();
    }

    protected void removeRange(int fromIndex, int toIndex) {
        throw new UnsupportedOperationException();
    }

    public Iterator<T> iterator() {
        return new Iterator<T>() {
            private Iterator<T> c = ImmutableList.super.iterator();
            public boolean hasNext() {
                return c.hasNext();
            }

            public T next() {
                return c.next();
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }

    public void clear() {
        throw new UnsupportedOperationException();
    }

    public ListIterator<T> listIterator(final int index) {
        return new ListIterator<T>() {
            private final ListIterator<T> c = ImmutableList.super.listIterator(index);
            public boolean hasNext() {
                return c.hasNext();
            }

            public T next() {
                return c.next();
            }

            public boolean hasPrevious() {
                return c.hasPrevious();
            }

            public T previous() {
                return c.previous();
            }

            public int nextIndex() {
                return c.nextIndex();
            }

            public int previousIndex() {
                return c.previousIndex();
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }

            public void set(T t) {
                throw new UnsupportedOperationException();
            }

            public void add(T t) {
                throw new UnsupportedOperationException();
            }
        };
    }
}


